package test.com.googlecode.likesql.converter;

import junit.framework.TestCase;

import com.googlecode.likesql.converter.ArrayExpConverter;
import com.googlecode.likesql.converter.Converter;
import com.googlecode.likesql.converter.ConverterTable;
import com.googlecode.likesql.converter.StringConverter;
import com.googlecode.likesql.expression.ArrayExp;

public class ArrayExpConverterTester extends TestCase {

	public void test_IntArray(){
		Converter cvt=new ArrayExpConverter();
		ArrayExp exp1=ArrayExp.array(new int[]{1,234,566,32,3254});
		
		assertEquals("1,234,566,32,3254",cvt.toSql(exp1));
		assertEquals("?,?,?,?,?",cvt.toTemplate(exp1));
	}
	
	public void test_ObjectArray(){
		Converter cvt=new ArrayExpConverter();
		ConverterTable table=ConverterTable.getInstance();
		table.register(String.class,new StringConverter());
		ArrayExp exp1=ArrayExp.array(new String[]{"tre5","h485",null});
		
		assertEquals("'tre5','h485',null",cvt.toSql(exp1));
		assertEquals("?,?,?",cvt.toTemplate(exp1));
		table.unregister(String.class);
	}
}
